package com.shoppingwebsite.service.impl;

import com.shoppingwebsite.dao.OrderDao;
import com.shoppingwebsite.domain.YtOrders;
import com.shoppingwebsite.domain.YtUser;
import com.shoppingwebsite.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;

    @Override
    public void add(YtUser user, String names, double priceAll) {
        //初始化一条订单数据
        YtOrders orders=new YtOrders();
        orders.setUserName(user.getUsername());
        orders.setTotalPrice(priceAll);
        orders.setAddress(user.getAddress());
        orders.setGoodsAll(names);
        orders.setLxfs(user.getTelephone());

        orderDao.add(orders);
    }

    @Override
    public List<YtOrders> getOrders(String username) {
        List<YtOrders> orders = orderDao.getOrders(username);
        return orders;
    }
}
